

#include <stdio.h>
#include "iwdg.h"
#include "device.h"
#include "gpio.h"
#include "nvic.h"

static  sj_int8  iwdg_device_open(struct file *file_node)
{
    return 0;
}

static  sj_int8  iwdg_device_write(struct file *file_node,sj_uint8 *data ,sj_int32 len,sj_loff_t * loff)
{
    struct iwdg_device_data *self_data = (struct iwdg_device_data *)(file_node->private_data);

    sj_iwdg_feed(&self_data->param);
    return 0;
}

static  sj_int8  iwdg_device_read(struct file *file_node,sj_uint8 *data ,sj_int32 len,sj_loff_t * loff)
{
    struct iwdg_device_data *self_data = (struct iwdg_device_data *)(file_node->private_data);


    return 0;
}

static  sj_int8  iwdg_device_close(struct file *file_node)
{
    return 0;
}

static sj_int8 iwdg_device_probe(struct device *dev)
{
    sj_int8 ret =0;
    sj_int8 i=0;
    struct iwdg_device_data *self_data =(struct iwdg_device_data *)dev->private_data;
    if(!self_data)
    {
        ret =-1;
        goto out;
    }

    struct rcc_lsi_periph *iwdg_lsi= self_data->rcc_apb;
    sj_iwdg_clock_config(iwdg_lsi);

    sj_iwdg_init(&self_data->param);
out:
    return ret;
}

static struct file_operations iwdg_opt =
{
    iwdg_device_open,
    iwdg_device_close,
    NULL,
    iwdg_device_read,
    iwdg_device_write,
    NULL,
    NULL,
    NULL,
};

static struct device_id_table iwdg_id_table[]=
{
    {"iwdg"},
    {NULL}
};

static struct device_driver iwdg_driver={
    "iwdg",
    iwdg_id_table,
    &iwdg_opt,
    iwdg_device_probe,
    NULL,
    NULL,
    NULL,
    NULL,
};


static DRIVER_MODULE_INIT(iwdg_driver)

